Vanilla javascript: How to access DOM elements properties through a function parameter